
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 2
 * @Author : WangRuoyu 
 * @Date : 2023/5/10 17:22
 */

#include "iostream"
#include "cstring"
#include "algorithm"

using namespace std;

int n, m;
const int N = 15;

struct window {
    int x1, x2, y1, y2, id;
} w[N];

int find(int x, int y) {
    for (int i = n; i >= 1; --i) {
        if (x >= w[i].x1 && x <= w[i].x2 && y >= w[i].y1 && y <= w[i].y2) {
            return i;
        }
    }
    return 0;
}

int main() {
    cin >> n >> m;

    for (int i = 1; i <= n; ++i) {
        int x1, x2, y1, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        w[i].x1 = x1;
        w[i].x2 = x2;
        w[i].y1 = y1;
        w[i].y2 = y2;
        w[i].id = i;
    }

    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        int index = find(x, y);
        if (index) {
            cout << w[index].id << endl;
            window ww = w[index];
            for (int j = index; j < n; ++j) {
                w[j] = w[j + 1];
            }
            w[n] = ww;
        } else {
            cout << "IGNORED" << endl;
        }
    }

    return 0;
}